import request from '@/utils/request'

// 获取会话自学习信息列表
export function getServerInfoArray (params) {
  var data = fromData(params)
  return request({
    url: '/assist/getServerInfoArray',
    method: 'post',
    data
  })
}

// 获取会话自学习列表
export function getServerArray (params) {
  var data = fromData(params)
  return request({
    url: '/assist/getServerArray',
    method: 'post',
    data
  })
}

// 获取会话自学习子列表
export function getServerChildArray (params) {
  var data = fromData(params)
  return request({
    url: '/assist/getServerChildArray',
    method: 'post',
    data
  })
}

// 智能辅助决策--获取组播多播会话自学习子列表
export function getBMServerChildArray (params) {
  var data = fromData(params)
  return request({
    url: '/assist/getBMServerChildArray',
    method: 'post',
    data
  })
}

// 智能辅助决策--获取组播多播会话自学习子列表客户端
export function getBMServerClientArray (params) {
  var data = fromData(params)
  return request({
    url: '/assist/getBMServerClientArray',
    method: 'post',
    data
  })
}

// 智能辅助决策--获取组播多播会话自学习信息列表
export function getBMServerInfoArray (params) {
  var data = fromData(params)
  return request({
    url: '/assist/getBMServerInfoArray',
    method: 'post',
    data
  })
}

// 获取自学习协议类型
export function getProtocol (params) {
  var data = fromData(params)
  return request({
    url: '/assist/getProtocol',
    method: 'post',
    data
  })
}

// 会话自学习智能生成策略
export function autoAddPolicy (params) {
  var data = fromData(params)
  return request({
    url: '/assist/autoAddPolicy',
    method: 'post',
    data
  })
}

// 获取会话自学习播地址列表
export function getServerAddrArray (params) {
  var data = fromData(params)
  return request({
    url: '/assist/getServerAddrArray',
    method: 'post',
    data
  })
}


// 获取会话自学习播地址列表
export function getServerClientArray (params) {
  var data = fromData(params)
  return request({
    url: '/assist/getServerClientArray',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
